import 'package:flutter/material.dart';

/// 一个统一的、可复用的 Picker 列表项 Widget。
/// 使用 RichText 解决了在窄屏幕上后缀文本被裁切的问题。
class PickerItem extends StatelessWidget {
  final String value;
  final String suffix;
  final bool isSelected;

  const PickerItem({
    super.key,
    required this.value,
    required this.suffix,
    required this.isSelected,
  });

  @override
  Widget build(BuildContext context) {
    final Color textColor =
    isSelected ? const Color(0xFF3482FF) : Colors.black54;
    final FontWeight fontWeight =
    isSelected ? FontWeight.bold : FontWeight.normal;
    final double valueFontSize = isSelected ? 24 : 18;
    final double suffixFontSize = isSelected ? 12 : 10;

    return Center(
      child: RichText(
        text: TextSpan(
          style: DefaultTextStyle.of(context).style,
          children: <TextSpan>[
            TextSpan(
              text: value,
              style: TextStyle(
                fontSize: valueFontSize,
                color: textColor,
                fontWeight: fontWeight,
              ),
            ),
            // 添加一个小的间距
            const TextSpan(text: ' '),
            TextSpan(
              text: suffix,
              style: TextStyle(
                fontSize: suffixFontSize,
                color: textColor,
                fontWeight: fontWeight,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
